package com.fixme4trade.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;

@Entity
public class Customer implements Serializable {	
	
	private static final long serialVersionUID = 1L;

	@Id
	//@GeneratedValue
	@SequenceGenerator( name = "CUSTOMER_ID", sequenceName = "CUSTOMER_SEQ", allocationSize = 1 )  
	@GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "CUSTOMER_ID" )
	@Column(name="customer_id")
	private Long id;
	
	@OneToOne(cascade=CascadeType.ALL, optional=false, fetch=FetchType.EAGER, orphanRemoval=false)    
    @PrimaryKeyJoinColumn
    private User user;
	
	@OneToMany(mappedBy = "customer")
	private List<Sell> purchases;
		
	@OneToMany(cascade=CascadeType.ALL, mappedBy = "owner")
	private List<CredictCard> credictCard = new ArrayList<CredictCard>();
	
	public Customer() {
		
	}
	
	public Long getId() {
		return id;
	}

	public void setId(final Long id) {
		this.id = id;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(final User user) {
		this.user = user;
	}
	
	public List<CredictCard> getCredictCard() {
		return credictCard;
	}

	public void setCredictCard(final List<CredictCard> credictCard) {
		this.credictCard = credictCard;
	}

	public List<Sell> getPurchases() {
		return purchases;
	}

	public void setPurchases(List<Sell> purchases) {
		this.purchases = purchases;
	}
}
